<template>
  <div class="todo-item">
    <input
      class="todo-input"
      type="checkbox"
      :checked="todo.done"
      @change="changeChecked"
    />
    <span>{{ todo.title }}</span>
    <button class="todo-button" @click="deleteTodo(todo.id)">删除</button>
  </div>
</template>

<script>
export default {
  name: "MyItem",
  props: ['todo', 'deleteTodoList'],
  methods: {
    changeChecked() {
        this.todo.done = !this.todo.done;
    },
    deleteTodo(id) {
        this.deleteTodoList(id);
    }
  },
};
</script>

<style scoped>
.todo-item {
  width: 400px;
  height: 25px;
  line-height: 25px;
  padding-left: 6px;
  border: 1px solid #ccc;
  margin: 0 auto;
  position: relative;
  color: #333;
  font-size: 16px;
  font-weight: 600;
  text-shadow: 0 0 3px #a4c5fe;
  text-align: start;
}
.todo-item:hover {
  border: 2px solid #a4c5fe;
  box-shadow: 2px 2px 5px #a4c5fe inset;
  cursor: pointer;
}
.todo-input {
  margin-right: 5px;
}
.todo-button {
  position: absolute;
  right: 0;
  top: 50%;
  margin-top: -10px;
  margin-right: 6px;
  line-height: 16px;
  background-color: #c72f32;
  border: 2px solid #c72f32;
  box-shadow: 2px 2px 3px #c72f32;
  border-radius: 5px;
  color: #fc5430;
  font-size: 14px;
  font-weight: 500;
  width: 40px;
  display: none;
}
.todo-item:hover .todo-button {
  display: inline-block;
}
</style>